package com.ctshk.rpc.goods.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctshk.rpc.goods.dto.ShoppingShopKeyWordsDTO;
import com.ctshk.rpc.goods.entity.ShoppingShopKeyWord;
import com.ctshk.rpc.goods.mapper.ShoppingShopKeyWordMapper;
import com.ctshk.rpc.goods.service.IShoppingShopKeyWordService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 商城关键词 服务实现类
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-04-06
 */
@Service
public class ShoppingShopKeyWordServiceImpl extends ServiceImpl<ShoppingShopKeyWordMapper, ShoppingShopKeyWord> implements IShoppingShopKeyWordService {

    @Autowired
    ShoppingShopKeyWordMapper shopKeyWordMapper;

    @Override
    public List<ShoppingShopKeyWordsDTO> findShoppingShopKeyWordsListByShopId(Long shopId) {
        List<ShoppingShopKeyWord> shoppingShopKeyWords = shopKeyWordMapper.findShoppingShopKeyWordsListByShopId(shopId);
        if(shoppingShopKeyWords != null){
            List<ShoppingShopKeyWordsDTO> shoppingShopKeyWordsDTOS = new ArrayList<>();
            for (ShoppingShopKeyWord shoppingShopKeyWord : shoppingShopKeyWords) {
                ShoppingShopKeyWordsDTO shoppingShopKeyWordsDTO = new ShoppingShopKeyWordsDTO();
                BeanUtils.copyProperties(shoppingShopKeyWord, shoppingShopKeyWordsDTO);
                shoppingShopKeyWordsDTOS.add(shoppingShopKeyWordsDTO);
            }
            return shoppingShopKeyWordsDTOS;
        }
        return new ArrayList<>();
    }
}
